<!DOCTYPE html>
<html  xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:f="http://java.sun.com/jsf/core">
    <head>
        <title>TODO supply a title</title>
    </head>
    <body>
        <ui:composition>
            <h:form id="emp">
                <rich:panel header="计划追加明细编制" styleClass="content-hight">
                    <h:panelGrid columns="7" id="firstGroup" style=" text-align: left" >
                        <h:outputLabel value="年度："/>
                        <h:selectOneMenu value="#{planAddEditGovBean.iyear}"
                                         style="width:90px;text-align: left">
                            <f:selectItem itemValue="0" itemLabel="-请选择-"/>
                            <f:selectItems value="#{planAddEditGovBean.yearli}"/>
                            <a4j:ajax event="change"
                                      render="@this,button,add"
                                      listener="#{planAddEditGovBean.yearChange}"/>
                        </h:selectOneMenu>
                        <h:outputLabel value="季度："/>
                        <h:selectOneMenu value="#{planAddEditGovBean.isession}"
                                         style="width:90px"
                                         disabled="#{planEditGovBean.iyear eq 0}"
                                         id="iseason">
                            <f:selectItem itemValue="" itemLabel="-请选择-"/>
                            <f:selectItem itemValue="1" itemLabel="第一季度" itemDisabled="#{planAddEditGovBean.isessionFor lt 1}" />
                            <f:selectItem itemValue="2" itemLabel="第二季度" itemDisabled="#{planAddEditGovBean.isessionFor lt 2}"/>
                            <f:selectItem itemValue="3" itemLabel="第三季度" itemDisabled="#{planAddEditGovBean.isessionFor lt 3}"/>
                            <f:selectItem itemValue="4" itemLabel="第四季度" itemDisabled="#{planAddEditGovBean.isessionFor lt 4}"/>
                            <a4j:ajax event="change" render="@this,button,add,tolbar,err" listener="#{planAddEditGovBean.changeListener}"/>
                        </h:selectOneMenu>
                        <h:outputLabel value="采购预算资金性质："/>
                        <h:selectOneMenu value="#{planAddEditGovBean.quality}"
                                         style="width:130px;">
                            <f:selectItem itemValue="" itemLabel="-请选择-"/>
                            <f:selectItem itemValue="0" itemLabel="基本支出"/>
                            <f:selectItem itemValue="1" itemLabel="项目支出"/>
                            <a4j:ajax event="change" render="@this,button,projName,add,err,tolbar" listener="#{planAddEditGovBean.changeListener}" />
                        </h:selectOneMenu>
                        <a4j:commandButton id="button" value="确定" action="#{planAddEditGovBean.query}"
                                           onclick="this.disabled = 'true';"
                                           render="tolbar,err,tableGroup,editGrid,editTable,editTable2"
                                           execute="@this"/>
                    </h:panelGrid>
                    <rich:toolbar id="tolbar">
                        <rich:toolbarGroup>
                            <a4j:commandButton id="add" value="新建" action="#{planAddEditGovBean.add}"
                                               execute="@this" render="tolbar,editGrid,err,editTable2"
                                               disabled="#{empty planAddEditGovBean.iyear and empty planAddEditGovBean.quality
                                                           or !planAddEditGovBean.forButton
                                                           or planAddEditGovBean.isession != planAddEditGovBean.isessionFor}"
                                               onclick="#{rich:component('budgetPanel')}.show();"/>
                            <a4j:commandButton value="编辑" action="#{planAddEditGovBean.update}"
                                               disabled="#{!planAddEditGovBean.forButton
                                                           or planAddEditGovBean.isession != planAddEditGovBean.isessionFor}"
                                               execute="@this" render="tolbar,editGrid,tableGroup"/>
                            <a4j:commandButton value="删除" action="#{planAddEditGovBean.delete}"
                                               disabled="#{!planAddEditGovBean.forButton
                                                           or planAddEditGovBean.isession != planAddEditGovBean.isessionFor}"
                                               execute="@form" render="tolbar,editGrid,tableGroup,err"/>
                            <a4j:commandButton value="保存" action="#{planAddEditGovBean.save}"
                                               execute="@form" render="tolbar,err,editGrid,tableGroup"
                                               disabled="#{!planAddEditGovBean.editStatus
                                                           or !planAddEditGovBean.forButton
                                                           or planAddEditGovBean.base == null
                                                           or empty planAddEditGovBean.base.number
                                                           or planAddEditGovBean.detail.status =='1'
                                                           or planAddEditGovBean.detail.status =='3'
                                                           or planAddEditGovBean.isession != planAddEditGovBean.isessionFor}"
                                               onclick="this.disabled = 'true';"/>
                            <a4j:commandButton value="提交" action="#{planAddEditGovBean.submitFor}"
                                               disabled="#{planAddEditGovBean.addOrUpdate
                                                           or planAddEditGovBean.editStatus
                                                           or !planAddEditGovBean.forButton
                                                           or planAddEditGovBean.isession != planAddEditGovBean.isessionFor}"
                                               execute="@this" render="tolbar,err,editGrid,tableGroup"/>
                            <a4j:commandButton value="撤消" action="#{planAddEditGovBean.canclFor}"
                                               disabled="#{planAddEditGovBean.addOrUpdate
                                                           or planAddEditGovBean.editStatus
                                                           or !planAddEditGovBean.forButton
                                                           or planAddEditGovBean.isession != planAddEditGovBean.isessionFor}"
                                               execute="@this" render="tolbar,err,editGrid,tableGroup"/>
                        </rich:toolbarGroup>
                    </rich:toolbar>
                    <h:outputLabel id="err" value="#{queryBean.err.errtip}" style="color:red"/>
                    <rich:notifyMessage stayTime="5000"/>
                    <h:panelGroup id="editGrid" rendered="#{planAddEditGovBean.addli != null and planAddEditGovBean.addli.size() != 0}" >
                        <rich:dataScroller for="editTable1" execute="@this" render="editGrid"/>
                        <div style="width:780px;overflow:auto;">
                            <rich:dataTable id="editTable1" value="#{planAddEditGovBean.addli}" var="emp"
                                            rowClasses="list-row-odd,list-row-even" rowKeyVar="rowKey"
                                            headerClass="table-header"
                                            noDataLabel="无数据!"
                                            style="width:1500px;margin-bottom: 20px;">
                                <rich:column>
                                    <f:facet name="header">序号</f:facet>
                                        #{rowKey+1}
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">类别</f:facet>
                                    <h:outputText value="#{emp.planWay}"/>
                                </rich:column>
                                <rich:column rendered="#{planAddEditGovBean.quality =='1'}" >
                                    <f:facet name="header">项目</f:facet>
                                    <h:outputText value="#{emp.project.finName}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">部门</f:facet>
                                    <h:outputText value="#{emp.deptName}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">处室</f:facet>
                                    <h:outputText value="#{emp.officeName}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">编报人</f:facet>
                                    <h:outputText value="#{emp.editPerName}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">品目</f:facet>
                                    <h:outputText value="#{emp.cate.name}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">计量单位</f:facet>
                                    <h:outputText value="#{emp.cate.unit}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">采购数量</f:facet>
                                    <h:inputText id="countId" value="#{emp.cate.count}" disabled="#{!planAddEditGovBean.editStatus}"
                                                 validatorMessage="数值不能超过9位！">
                                        <f:validateDoubleRange maximum="999999999"/>
                                        <a4j:ajax event="blur" execute="@this" render="@this,messageC"/>
                                    </h:inputText>
                                    <h:message id="messageC" for="countId" style="color:red"/>
                                </rich:column>
                                <rich:column style="text-align: right;width:120px">
                                    <f:facet name="header">财政性资金</f:facet>
                                    <h:inputText id="financialId" value="#{emp.financial}" disabled="#{!planAddEditGovBean.editStatus}"
                                                 converterMessage="请输入数值!">
                                        <a4j:ajax event="blur" execute="@this" render="@this,messageF"/>
                                        <f:convertNumber type="number" pattern="#,##0.00"/>
                                    </h:inputText>
                                    <h:message id="messageF" for="financialId" style="color:red"/>
                                </rich:column>
                                <rich:column style="text-align:right;width:120px">
                                    <f:facet name="header">其他资金</f:facet>
                                    <h:inputText id="otherId" value="#{emp.other}" disabled="#{!planAddEditGovBean.editStatus}"
                                                 converterMessage="请输入数值!">
                                        <a4j:ajax event="blur" execute="@this" render="@this,messageO"/>
                                        <f:convertNumber type="number" pattern="#,##0.00"/>
                                    </h:inputText>
                                    <h:message id="messageO" for="otherId" style="color:red"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">组织形式</f:facet>
                                    <h:outputText value="集中采购" rendered="#{emp.organizeForm == '0'}"/>
                                    <h:outputText value="部门集中采购" rendered="#{emp.organizeForm == '1'}"/>
                                    <h:outputText value="分散采购" rendered="#{emp.organizeForm == '2'}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">委托的集中采购机构</f:facet>
                                    <h:outputText value="#{emp.organ}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">采购方式</f:facet>
                                    <h:outputText value="公开招标" rendered="#{emp.cateWay == '0'}"/>
                                    <h:outputText value="邀请招标" rendered="#{emp.cateWay == '1'}"/>
                                    <h:outputText value="竞争性谈判" rendered="#{emp.cateWay == '2'}"/>
                                    <h:outputText value="单一来源" rendered="#{emp.cateWay == '3'}"/>
                                    <h:outputText value="询价" rendered="#{emp.cateWay == '4'}"/>
                                </rich:column>      
                                <rich:column>
                                    <f:facet name="header">备注</f:facet>
                                    <h:outputText value="#{emp.memo}"/>
                                </rich:column>                              

                                <rich:column style="width:80px;text-align:center">
                                    <f:facet name="header">操作</f:facet>
                                    <a4j:commandLink action="#{showFlowInfoBean.showFlowInfo(emp.id,'1')}"
                                                     oncomplete="#{rich:component('checkInfoPanel')}.show();"
                                                     render="infoPanel">
                                        <h:outputText value="审批信息"/>
                                    </a4j:commandLink>
                                </rich:column>

                                <f:facet name="footer"/>
                            </rich:dataTable>
                        </div>
                    </h:panelGroup>
                    <hr/>
                    <h:panelGroup id="tableGroup">
                        <rich:dataScroller for="editTable" execute="@this" render="tableGroup"/>
                        <div style="width:780px;max-height:300px;overflow:auto;">
                            <rich:dataTable id="editTable" value="#{planAddEditGovBean.detailModel}" var="emp"
                                            rowClasses="list-row-odd,list-row-even" rowKeyVar="rowKey"
                                            headerClass="table-header"
                                            noDataLabel="无数据!"
                                            style="width:1500px;margin-bottom: 20px;">
                                <rich:column>
                                    <f:facet name="header">
                                        <h:selectBooleanCheckbox  value="#{planAddEditGovBean.all}">
                                            <a4j:ajax event="click" render="@this,editTable" execute="@this"
                                                      listener="#{planAddEditGovBean.selectdAllDetail}" />
                                        </h:selectBooleanCheckbox>
                                    </f:facet>
                                    <h:selectBooleanCheckbox value="#{emp.selected}">
                                        <a4j:ajax event="click" render="@this" execute="@this" />
                                    </h:selectBooleanCheckbox>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">序号</f:facet>
                                        #{rowKey+1}
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">类别</f:facet>
                                    <h:outputText value="#{emp.planWay}"/>
                                </rich:column>
                                <rich:column rendered="#{planAddEditGovBean.quality =='1'}" >
                                    <f:facet name="header">项目</f:facet>
                                    <h:outputText value="#{emp.project.finName}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">部门</f:facet>
                                    <h:outputText value="#{emp.deptName}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">处室</f:facet>
                                    <h:outputText value="#{emp.officeName}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">编报人</f:facet>
                                    <h:outputText value="#{emp.editPerName}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">状态</f:facet>
                                    <h:outputText value="未提交"  rendered="#{emp.status == '0'}"/>
                                    <h:outputText value="已提交等待审核"  rendered="#{emp.status == '1'}" style="color:blue"/>
                                    <h:outputText value="审核通过"  rendered="#{emp.status == '3'}" style="color:green"/>
                                    <h:outputText value="退回修改"  rendered="#{emp.status == '2'}" style="color:red"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">品目</f:facet>
                                    <h:outputText value="#{emp.cate.name}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">计量单位</f:facet>
                                    <h:outputText value="#{emp.cate.unit}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">采购数量</f:facet>
                                    <h:inputText id="count" value="#{emp.cate.count}"
                                                 disabled="#{!planAddEditGovBean.editStatus or emp.status == '1' or emp.status == '3' or emp.selected == false}"
                                                 validatorMessage="数值不能超过9位！">
                                        <f:validateDoubleRange maximum="999999999"/>
                                        <a4j:ajax event="blur" execute="@this" render="@this,messageCt"/>
                                    </h:inputText>
                                    <h:message id="messageCt" for="count" style="color:red"/>
                                </rich:column>
                                <rich:column style="text-align: right;width:120px">
                                    <f:facet name="header">财政性资金</f:facet>
                                    <h:inputText id="financial" value="#{emp.financial}"
                                                 disabled="#{!planAddEditGovBean.editStatus or emp.status == '1' or emp.status == '3' or emp.selected == false}"
                                                 converterMessage="请输入数值!">
                                        <a4j:ajax event="blur" execute="@this" render="@this,messageFl"/>
                                        <f:convertNumber type="number" pattern="#,##0.00"/>
                                    </h:inputText>
                                    <h:message id="messageFl" for="financial" style="color:red"/>
                                </rich:column>
                                <rich:column style="text-align:right;width:120px">
                                    <f:facet name="header">其他资金</f:facet>
                                    <h:inputText id="other" value="#{emp.other}"
                                                 disabled="#{!planAddEditGovBean.editStatus or emp.status == '1' or emp.status == '3' or emp.selected == false}"
                                                 converterMessage="请输入数值!">
                                        <a4j:ajax event="blur" execute="@this" render="@this,messageOt"/>
                                        <f:convertNumber type="number" pattern="#,##0.00"/>
                                    </h:inputText>
                                    <h:message id="messageOt" for="other" style="color:red"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">组织形式</f:facet>
                                    <h:outputText value="集中采购" rendered="#{emp.organizeForm == '0'}"/>
                                    <h:outputText value="部门集中采购" rendered="#{emp.organizeForm == '1'}"/>
                                    <h:outputText value="分散采购" rendered="#{emp.organizeForm == '2'}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">委托的集中采购机构</f:facet>
                                    <h:outputText value="#{emp.organ}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">采购方式</f:facet>
                                    <h:outputText value="公开招标" rendered="#{emp.cateWay == '0'}"/>
                                    <h:outputText value="邀请招标" rendered="#{emp.cateWay == '1'}"/>
                                    <h:outputText value="竞争性谈判" rendered="#{emp.cateWay == '2'}"/>
                                    <h:outputText value="单一来源" rendered="#{emp.cateWay == '3'}"/>
                                    <h:outputText value="询价" rendered="#{emp.cateWay == '4'}"/>
                                </rich:column>
                                <rich:column>
                                    <f:facet name="header">备注</f:facet>
                                    <h:outputText value="#{emp.memo}"/>
                                </rich:column>
                                <f:facet name="footer"/>
                            </rich:dataTable>
                        </div>
                    </h:panelGroup>
                </rich:panel>
            </h:form>

            <rich:popupPanel id="budgetPanel" autosized="true" width="800" height="550">
                <f:facet name="header">预算追加列表</f:facet>
                <f:facet name="controls">
                    <h:outputLink value="#" onclick="#{rich:component('budgetPanel')}.hide();
                                                   return false;">关闭</h:outputLink>
                </f:facet>
                <h:form>
                    <rich:panel>
                        <h:commandButton value="确定" action="#{planAddEditGovBean.addForPlan}"
                                         onclick="#{rich:component('budgetPanel')}.hide();"/>
                        <div style="height:430px;overflow:auto;">
                            <h:panelGroup id="tableGroup2">
                                <div style="width:750px;max-height:300px;overflow:auto;">
                                    <rich:dataTable id="editTable2" value="#{planAddEditGovBean.budgetModel}" var="emp"
                                                    rowClasses="list-row-odd,list-row-even" rowKeyVar="rowKey"
                                                    headerClass="table-header"
                                                    noDataLabel="无数据!"
                                                    style="width:1500px;">
                                        <rich:column>
                                            <f:facet name="header">
                                                <h:selectBooleanCheckbox  value="#{planAddEditGovBean.budgetall}">
                                                    <a4j:ajax event="click" render="@this,editTable2" execute="@this"
                                                              listener="#{planAddEditGovBean.selectdAll}" />
                                                </h:selectBooleanCheckbox>
                                            </f:facet>
                                            <h:selectBooleanCheckbox value="#{emp.selected}">
                                                <a4j:ajax event="click" render="@this" execute="@this"/>
                                            </h:selectBooleanCheckbox>
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">序号</f:facet>
                                                #{rowKey+1}
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">类别</f:facet>
                                            <h:outputText value="#{emp.planWay}"/>
                                        </rich:column>
                                        <rich:column rendered="#{planAddEditGovBean.quality =='1'}" >
                                            <f:facet name="header">项目</f:facet>
                                            <h:outputText value="#{emp.project.finName}"/>
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">部门</f:facet>
                                            <h:outputText value="#{emp.deptName}"/>
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">处室</f:facet>
                                            <h:outputText value="#{emp.officeName}"/>
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">编报人</f:facet>
                                            <h:outputText value="#{emp.editPerName}"/>
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">状态</f:facet>
                                            <h:outputText value="未提交"  rendered="#{emp.status == '0'}"/>
                                            <h:outputText value="已提交等待审核"  rendered="#{emp.status == '1'}" style="color:blue"/>
                                            <h:outputText value="审核通过"  rendered="#{emp.status == '3'}" style="color:green"/>
                                            <h:outputText value="退回修改"  rendered="#{emp.status == '2'}" style="color:red"/>
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">品目</f:facet>
                                            <h:outputText value="#{emp.cate.name}"/>
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">计量单位</f:facet>
                                            <h:outputText value="#{emp.cate.unit}"/>
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">采购数量</f:facet>
                                            <h:outputText value="#{emp.cate.count}"/>
                                        </rich:column>
                                        <rich:column style="text-align: right;width:120px">
                                            <f:facet name="header">财政性资金</f:facet>
                                            <h:outputText value="#{emp.financial}">
                                                <f:convertNumber type="number" pattern="#,##0.00"/>
                                            </h:outputText>
                                        </rich:column>
                                        <rich:column style="text-align:right;width:120px">
                                            <f:facet name="header">其他资金</f:facet>
                                            <h:outputText value="#{emp.other}">
                                                <f:convertNumber type="number" pattern="#,##0.00"/>
                                            </h:outputText>
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">组织形式</f:facet>
                                            <h:outputText value="集中采购" rendered="#{emp.organizeForm == '0'}"/>
                                            <h:outputText value="部门集中采购" rendered="#{emp.organizeForm == '1'}"/>
                                            <h:outputText value="分散采购" rendered="#{emp.organizeForm == '2'}"/>
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">委托的集中采购机构</f:facet>
                                            <h:outputText value="#{emp.organ}"/>
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">采购方式</f:facet>
                                            <h:outputText value="公开招标" rendered="#{emp.cateWay == '0'}"/>
                                            <h:outputText value="邀请招标" rendered="#{emp.cateWay == '1'}"/>
                                            <h:outputText value="竞争性谈判" rendered="#{emp.cateWay == '2'}"/>
                                            <h:outputText value="单一来源" rendered="#{emp.cateWay == '3'}"/>
                                            <h:outputText value="询价" rendered="#{emp.cateWay == '4'}"/>
                                        </rich:column>
                                        <rich:column>
                                            <f:facet name="header">备注</f:facet>
                                            <h:outputText value="#{emp.memo}"/>
                                        </rich:column>
                                        <f:facet name="footer"/>
                                    </rich:dataTable>
                                </div>
                            </h:panelGroup>
                        </div>
                    </rich:panel>
                </h:form>
            </rich:popupPanel>

            <rich:popupPanel id="checkInfoPanel" autosized="true" width="500" height="500">
                <f:facet name="header">项目列表</f:facet>
                <f:facet name="controls">
                    <h:outputLink value="#" onclick="#{rich:component('checkInfoPanel')}.hide();
                                                   return false;">关闭</h:outputLink>
                </f:facet>
                <h:form>
                    <rich:panel id="infoPanel">
                        <ui:include src="/page/checkflow/checkInfo.xhtml"/>
                    </rich:panel>
                </h:form>
            </rich:popupPanel>

        </ui:composition>
    </body>
</html>
